import 'package:wch/generated/json/base/json_convert_content.dart';
import 'package:wch/model/hospital.dart';

HospitalModel $HospitalModelFromJson(Map<String, dynamic> json) {
  final HospitalModel hospitalModel = HospitalModel();
  final String? code = jsonConvert.convert<String>(json['code']);
  if (code != null) {
    hospitalModel.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    hospitalModel.msg = msg;
  }
  final List<HospitalData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<HospitalData>(e) as HospitalData).toList();
  if (data != null) {
    hospitalModel.data = data;
  }
  return hospitalModel;
}

Map<String, dynamic> $HospitalModelToJson(HospitalModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  return data;
}

extension HospitalModelExtension on HospitalModel {
  HospitalModel copyWith({
    String? code,
    String? msg,
    List<HospitalData>? data,
  }) {
    return HospitalModel()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

HospitalData $HospitalDataFromJson(Map<String, dynamic> json) {
  final HospitalData hospitalData = HospitalData();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    hospitalData.id = id;
  }
  final String? hospitalName = jsonConvert.convert<String>(
      json['hospitalName']);
  if (hospitalName != null) {
    hospitalData.hospitalName = hospitalName;
  }
  final String? sex = jsonConvert.convert<String>(json['sex']);
  if (sex != null) {
    hospitalData.sex = sex;
  }
  return hospitalData;
}

Map<String, dynamic> $HospitalDataToJson(HospitalData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['hospitalName'] = entity.hospitalName;
  data['sex'] = entity.sex;
  return data;
}

extension HospitalDataExtension on HospitalData {
  HospitalData copyWith({
    String? id,
    String? hospitalName,
    String? sex,
  }) {
    return HospitalData()
      ..id = id ?? this.id
      ..hospitalName = hospitalName ?? this.hospitalName
      ..sex = sex ?? this.sex;
  }
}